package com.lmiot.xyclick.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.lmiot.xyclick.Util.SpFlag;
import com.lmiot.xyclick.AD.SDK.ADSDK;
import com.lmiot.xyclick.App.MyApp;
import com.lmiot.xyclick.Bean.LoginDevSuccessBean;
import com.lkx.liandianqinew.R;
import com.lmiot.xyclick.Util.DataUtil;
import com.lmiot.xyclick.Util.EditDialogUtil;
import com.lmiot.xyclick.Util.HttpUtilNew;
import com.lmiot.xyclick.Util.LogUtil;
import com.lmiot.xyclick.Util.StateBarUtil;
import com.lmiot.xyclick.Util.TimeUtils;
import com.lmiot.xyclick.inteface.OnBasicListener;
import com.youyi.yypermissionlibrary.SDK.OnPerListener;
import com.youyi.yypermissionlibrary.SDK.YYPerUtils;
import com.youyi.yyviewsdklibrary.Dialog.util.ToastUtil;
import com.youyi.yyviewsdklibrary.LoadingDialog;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class LoginActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "LoginActivity";
    TextView mDPrivate;
    TextView mDServer;
    ImageView mIdBack;
    CheckBox mIdCheckbox;
    LinearLayout mIdCheckboxLayout;
    private LinearLayout mIdLoginPhone;
    LinearLayout mIdLoginWx;
    LinearLayout mIdRemain;
    private Intent mIntent;

    /* access modifiers changed from: protected */
    @Override // android.support.v4.app.SupportActivity, com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_login);
        initView();
        StateBarUtil.immersive(this);
        StateBarUtil.setPadding(this, this.mIdRemain);
        EventBus.getDefault().register(this);
        this.mIdLoginWx.setOnLongClickListener(new View.OnLongClickListener() {
            /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass1 */

            public boolean onLongClick(View view) {
                LoginActivity.this.mIdCheckbox.setChecked(true);
                EditDialogUtil.getInstance().edit(LoginActivity.this, 1, "请输入微信编号", "如：01、02、03", DataUtil.getWxNum(MyApp.getContext()), new EditDialogUtil.EditMethod() {
                    /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass1.AnonymousClass1 */

                    @Override // com.lmiot.xyclick.Util.EditDialogUtil.EditMethod
                    public void edit(String str) {
                        DataUtil.setWxNum(MyApp.getContext(), str);
                        MyApp.getInstance().loginWx();
                    }
                }, false);
                return true;
            }
        });
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(LoginDevSuccessBean loginDevSuccessBean) {
        LoadingDialog.hidden();
        DataUtil.setLoginByWx(MyApp.getContext(), false);
        DataUtil.setSessionID(MyApp.getContext(), TimeUtils.createSessionID());
        HttpUtilNew.getInstance().regist(new OnBasicListener() {
            /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass2 */

            @Override // com.lmiot.xyclick.inteface.OnBasicListener
            public void result(boolean z, String str) {
                if (z) {
                    ToastUtil.success("登录本机成功！");
                    HttpUtilNew.getInstance().findUserBean(new HttpUtilNew.OnUserBeanListener() {
                        /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass2.AnonymousClass1 */

                        @Override // com.lmiot.xyclick.Util.HttpUtilNew.OnUserBeanListener
                        public void result(boolean z) {
                            Log.d(LoginActivity.TAG, "DataUtilgetVip(MyApp.getContext()):" + DataUtil.getVip(MyApp.getContext()));
                            LoginActivity.this.finish();
                        }
                    }, new HttpUtilNew.OnOffLine() {
                        /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass2.AnonymousClass2 */

                        @Override // com.lmiot.xyclick.Util.HttpUtilNew.OnOffLine
                        public void result(boolean z) {
                        }
                    });
                    return;
                }
                ToastUtil.err("登录失败，请检查手机网络或重启一次APP！");
            }
        });
    }

    /* access modifiers changed from: protected */
    @Override // com.lmiot.xyclick.Activity.BaseActivity, android.support.v7.app.AppCompatActivity, android.support.v4.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    private void initView() {
        this.mIdRemain = (LinearLayout) findViewById(R.id.id_remain);
        this.mIdBack = (ImageView) findViewById(R.id.id_back);
        this.mIdLoginWx = (LinearLayout) findViewById(R.id.id_login_wx);
        this.mIdCheckbox = (CheckBox) findViewById(R.id.id_checkbox);
        this.mDServer = (TextView) findViewById(R.id.d_server);
        this.mDPrivate = (TextView) findViewById(R.id.d_private);
        this.mIdCheckboxLayout = (LinearLayout) findViewById(R.id.id_checkbox_layout);
        this.mIdBack.setOnClickListener(this);
        this.mIdLoginWx.setOnClickListener(this);
        this.mIdCheckbox.setOnClickListener(this);
        this.mDServer.setOnClickListener(this);
        this.mDPrivate.setOnClickListener(this);
        this.mIdCheckboxLayout.setOnClickListener(this);
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.id_login_phone);
        this.mIdLoginPhone = linearLayout;
        linearLayout.setOnClickListener(this);
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.d_private /*{ENCODED_INT: 2131296385}*/:
                Intent intent = new Intent(this, WebViewActivity.class);
                this.mIntent = intent;
                intent.putExtra(SpFlag.k, "《隐私政策》");
                if (ADSDK.nowVersion.startsWith("HW")) {
                    this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/privateh.html");
                } else {
                    this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/private.html");
                }
                startActivity(this.mIntent);
                return;
            case R.id.d_server /*{ENCODED_INT: 2131296386}*/:
                Intent intent2 = new Intent(this, WebViewActivity.class);
                this.mIntent = intent2;
                intent2.putExtra(SpFlag.k, "《服务协议》");
                if (ADSDK.nowVersion.startsWith("HW")) {
                    this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/serverh.html");
                } else {
                    this.mIntent.putExtra("url", "https://ai.xiaoyizhineng.com:441/download/HelpVideo/autoclick/server.html");
                }
                startActivity(this.mIntent);
                return;
            case R.id.id_back /*{ENCODED_INT: 2131296478}*/:
                finish();
                return;
            case R.id.id_checkbox_layout /*{ENCODED_INT: 2131296540}*/:
                if (this.mIdCheckbox.isChecked()) {
                    this.mIdCheckbox.setChecked(false);
                    return;
                } else {
                    this.mIdCheckbox.setChecked(true);
                    return;
                }
            case R.id.id_login_phone /*{ENCODED_INT: 2131296760}*/:
                if (!this.mIdCheckbox.isChecked()) {
                    ToastUtil.err("请先勾选并阅读隐私政策后再登录");
                    return;
                } else {
                    YYPerUtils.sd(this, "本机登录需要申请存储权限哦", new OnPerListener() {
                        /* class com.lmiot.xyclick.Activity.LoginActivity.AnonymousClass4 */

                        @Override // com.youyi.yypermissionlibrary.SDK.OnPerListener
                        public void result(boolean z, String str) {
                            if (z) {
                                LoadingDialog.show(LoginActivity.this, LoadingDialog.DialogType.CENTER, true, "");
                                MyApp.getInstance().loginByPhone(LoginActivity.this);
                            }
                        }
                    });
                    return;
                }
            case R.id.id_login_wx /*{ENCODED_INT: 2131296761}*/:
                if (!this.mIdCheckbox.isChecked()) {
                    ToastUtil.err("请先勾选并阅读隐私政策后再登录");
                    return;
                } else {
                    MyApp.getInstance().loginWx();
                    return;
                }
            default:
                return;
        }
    }
}
